<?php echo $this->Form->create('Paginate', array('id' => 'paginate', 'url' => $this->request->here(false), 'type' => 'post', 'inputDefaults' => array('label' => false))); ?>                           
<div id="content-header">
    <h1><?php echo __d('system','Contact Management');?></h1>
</div>
<div id="breadcrumb">
    <a href="<?php echo $this->Html->url('/admin/')?>" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> <?php echo __d('system','Home');?></a>
    <a href="#" class="current"><?php echo __d('system','List Contact');?></a>
</div>
<div class="container-fluid">
<div class="row-fluid">
    <div class="span12">                      
    <?php echo $this->Session->flash(); ?> 
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                    <i class="icon-th"></i>
                </span>
                <h5><?php echo __d('system','List of Contact');?></h5>
            </div>
            <!--For contact normal-->
                <div class="widget-content widget-content-two">
                <div class="wd-select">
                    <div class="control-group">
                        <div class="controls wd-farming">
                            <select>
                                <option /><?php echo __d('system','Delete');?>
                            </select>
                            <?php 
                                $lstStatus = array(
                                    '1'=>__d('system','Đã đọc'),
                                    '2'=>__d('system','Chưa đọc'),
                                    '3'=>__d('system','Quan trọng'),
                                    '4'=>__d('system','Gắn dấu sao')
                                );
                                echo $this->Form->input('statusNode',array(
                                            'type'=>'select',                                            
                                            'div'=>false,
                                            'style'=>array('min-width:150px'),
                                            'label'=>false,
                                            'empty'=>__d('system','--- Tất cả ---'),
                                            /*'default'=>$default_show, */
                                            'options'=>$lstStatus
                                        ));                                                                        
                            ?>
                            <button class="btn"><?php echo __d('system','Apply');?></button>
                        </div>
                    </div>
                </div>
                <table class="table table-bordered data-table table-striped with-check wd-hover-btn">
                    <thead>
                        <tr>
                            <th style="min-width: 60px; text-align: justify;"><input type="checkbox" id="title-table-checkbox" name="title-table-checkbox" /></th>
                            <th> <?php echo  __d('system', 'Name'); ?></th>
                            <th> <?php echo  __d('system', 'Email'); ?></th>
                            <th> <?php echo  __d('system', 'Title'); ?></th>                                                
                            <th> <?php echo  __d('system', 'Status'); ?></th> 
                            <th class="wd-fix-width-2" style="min-width: 200px;"><?php echo  __d('system', 'Action'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                            $defaultLanguage = Router::defaultLanguage();
                            $_queries = array('continue' => $this->request->here(false));
                        ?> 
                        <?php foreach ($contacts as $contact) :?>                                            
                            <tr>
                                <td>
                                    <input type="checkbox" name="data[Paginate][chk_node_type][]" value="<?php echo $contact['Contact']['id'];?>"/>                                                                                                            
                                    <!--Important-->                                                                            
                                    <input type="checkbox" nme="data[Paginate][chk_important][]" value="<?php echo $contact['Contact']['id'];?>" title="<?php echo __d('system','Important');?>" onclick="return add_important('<?php echo $contact['Contact']['id'];?>')" class="input_importamt_<?php echo $contact['Contact']['id'];?>" />                                                                                                                                                                                              
                                    <!--End-->
                                    <!--Favourite-->                                                                        
                                    <input type="checkbox" name="data[Paginate][chk_favourite][]" value="<?php echo $contact['Contact']['id'];?>" title="<?php echo __d('system','Favourite');?>" onclick="return add_favourite('<?php echo $contact['Contact']['id'];?>')" class="input_favourite_<?php echo $contact['Contact']['id'];?>" />                                                                                                                
                                    <!--End-->                                    
                                </td>            
                                <td>
                                    <a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => 'node', 'action' => 'edit_contact',$contact['Contact']['id'], '?' => $_queries));?>"> <?php echo $contact['Contact']['name']; ?></a>
                                </td>                                                                                                                                         
                                <td>
                                    <?php echo $contact['Contact']['email']; ?>
                                </td>                                                                                         
                                <td>
                                    <?php echo $contact['Contact']['title'];?>
                                </td>                        
                                <td>
                                    <?php if($contact['Contact']['status']==1):?>                                    
                                        <img src="<?php echo $this->Html->webroot('img/mail_message-edit.png')?>" width="20px" height="20px" align="middle" alt="" style="display: block;margin: auto;">                                        
                                    <?php else:?>
                                        <img src="<?php echo $this->Html->webroot('img/mail-message-new.png')?>" width="20px" height="20px" alt="" style="display: block;margin: auto;">                                                                                
                                    <?php endif;?>                                                
                                </td>
                                <td>
                                    <ul class="wd-link-control">                                        
                                        <li><a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => 'node', 'action' => 'edit_contact',$contact['Contact']['id'], '?' => $_queries));?>" class="btn btn-mini"><i class="icon-edit"></i> <?php echo __d('system','Edit');?></a></li>                                        
                                        <li><a href="#<?php echo $contact['Contact']['id']?>" data-toggle="modal" class="btn btn-mini"><i class="icon-remove"></i> <?php echo __d('system','Delete');?></a></li>                                        
                                    </ul>
                                </td>
                            </tr>
                            <div id="myAlert" class="modal hide">
                                <div class="modal-header">
                                    <button data-dismiss="modal" class="close" type="button">×</button>
                                    <h3><?php echo __d('system','Alert');?></h3>
                                </div>
                                <div class="modal-body">
                                    <p><?php echo __d('system','Are you sure delete');?> “<?php echo $contact['Contact']['name']?>”?</p>
                                </div>
                                <div class="modal-footer">
                                    <a data-dismiss="modal" class="btn" href="#"><?php echo __d('system','Cancel');?></a>
                                    <?php echo $this->Html->link('Delete', array('plugin'=>'node','controller' => 'node','action' => 'delete', '?' => array_merge($_queries, array('keys' => array($contact['Contact']['id'])))), array('title' => false, 'class' => 'btn btn-danger','data-dismiss='=>'modal')); ?>                        
                                </div>
                            </div>                                                       
                            <?php endforeach?>                        
                    </tbody>
                    <?php foreach ($contacts as $contact) : ?> 
                        <div id="<?php echo $contact['Contact']['id']?>" class="modal hide">
                            <div class="modal-header">
                                <button data-dismiss="modal" class="close" type="button">×</button>
                                <h3><?php echo __d('system','Alert modal');?></h3>
                            </div>
                            <div class="modal-body">
                                <p><?php echo __d('system','Are you sure delete');?> “<?php echo $contact['Contact']['name'];?>”?</p>
                            </div>
                            <div class="modal-footer">
                                <a data-dismiss="modal" class="btn" href="#"><?php echo __d('system','Cancel');?></a>
                                <?php echo $this->Html->link('Delete', array('plugin'=>'node','controller' => 'node','action' => 'delete_multiple', '?' => array_merge($_queries, array('keys' => array($contact['Contact']['id']),'model'=>'Contact','linkAction'=>'manage_contact'))), array('title' => false, 'class' => 'btn btn-danger','data-dismiss='=>'modal')); ?>                        
                            </div>
                        </div>  
                        <?php endforeach?>                    
                </table>

                <div class="wd-select">

                    <div class="control-group">
                        <div class="controls wd-farming">
                            <select>
                                <option /><?php echo __d('system','Delete');?>
                            </select>                            
                            <?php 
                                $lstStatus = array(
                                    '1'=>__d('system','Đã đọc'),
                                    '2'=>__d('system','Chưa đọc'),
                                    '3'=>__d('system','Quan trọng'),
                                    '4'=>__d('system','Gắn dấu sao')
                                );
                                echo $this->Form->input('statusNode',array(
                                            'type'=>'select',                                            
                                            'div'=>false,
                                            'style'=>array('min-width:150px'),
                                            'label'=>false,
                                            'empty'=>__d('system','--- Tất cả ---'),
                                            /*'default'=>$default_show, */
                                            'options'=>$lstStatus
                                        ));                                                                        
                            ?>
                            <button class="btn"><?php echo __d('system','Apply');?></button>
                        </div>
                    </div>
                </div>                                
            </div>
            <!--End-->
            <!--for contact move from subsite other-->
                <!--<div class="widget-content widget-content-two">
                <div class="wd-select">
                    <div class="control-group">
                        <div class="controls wd-farming">
                            <span class="lbl-moved"><?php echo __d('system','Thông tin liên hệ được chuyển từ các phòng ban khác');?></span>
                        </div>
                    </div>
                </div>
                <table class="table table-bordered data-table table-striped with-check wd-hover-btn">
                    <thead>
                        <tr>
                            <th><input type="checkbox" id="title-table-checkbox" name="title-table-checkbox" /></th>
                            <th> <?php echo  __d('system', 'Name'); ?></th>
                            <th> <?php echo  __d('system', 'Email'); ?></th>
                            <th> <?php echo  __d('system', 'Title'); ?></th>                                                
                            <th class="wd-fix-width-2" style="min-width: 200px;"><?php echo  __d('system', 'Action'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                            $defaultLanguage = Router::defaultLanguage();
                            $_queries = array('continue' => $this->request->here(false));
                        ?> 
                        <?php foreach ($moveContacts as $moveContact) :?>                                            
                            <tr>
                                <td><input type="checkbox" name="data[Paginate][chk_node_type][]" value="<?php echo $moveContact['Contact']['id'];?>"/></td>            
                                <td>
                                    <a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => 'node', 'action' => 'edit_management',$moveContact['Contact']['id'], '?' => $_queries));?>"> <?php echo $moveContact['Contact']['name']; ?></a>
                                </td>                                                                                                                                         
                                <td>
                                    <?php echo $moveContact['Contact']['email']; ?>
                                </td>                                                                                         
                                <td>
                                    <?php echo $moveContact['Contact']['title'];?>
                                </td>                        
                                <td>
                                    <ul class="wd-link-control">                                        
                                        <li><a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => 'node', 'action' => 'edit_contact',$moveContact['Contact']['id'], '?' => $_queries));?>" class="btn btn-mini"><i class="icon-edit"></i> <?php echo __d('system','Edit');?></a></li>                                        
                                        <li><a href="#<?php echo $moveContact['MoveContact']['id']?>" data-toggle="modal" class="btn btn-mini"><i class="icon-remove"></i> <?php echo __d('system','Not received');?></a></li>                                        
                                    </ul>
                                </td>
                            </tr>
                            <div id="myAlert" class="modal hide">
                                <div class="modal-header">
                                    <button data-dismiss="modal" class="close" type="button">×</button>
                                    <h3><?php echo __d('system','Alert');?></h3>
                                </div>
                                <div class="modal-body">
                                    <p><?php echo __d('system','Are you sure not received');?> “<?php echo $moveContact['Contact']['name']?>”?</p>
                                </div>
                                <div class="modal-footer">
                                    <a data-dismiss="modal" class="btn" href="#"><?php echo __d('system','Cancel');?></a>
                                    <?php echo $this->Html->link('Delete', array('plugin'=>'node','controller' => 'node','action' => 'delete', '?' => array_merge($_queries, array('keys' => array($moveContact['MoveContact']['id'])))), array('title' => false, 'class' => 'btn btn-danger','data-dismiss='=>'modal')); ?>                        
                                </div>
                            </div>                                                       
                            <?php endforeach?>                        
                    </tbody>
                    <?php foreach ($moveContacts as $moveContact) : ?> 
                        <div id="<?php echo $moveContact['MoveContact']['id']?>" class="modal hide">
                            <div class="modal-header">
                                <button data-dismiss="modal" class="close" type="button">×</button>
                                <h3><?php echo __d('system','Alert modal');?></h3>
                            </div>
                            <div class="modal-body">
                                <p><?php echo __d('system','Are you sure not received');?> “<?php echo $moveContact['Contact']['name'];?>”?</p>
                            </div>
                            <div class="modal-footer">
                                <a data-dismiss="modal" class="btn" href="#"><?php echo __d('system','Cancel');?></a>
                                <?php echo $this->Html->link('Not Received', array('plugin'=>'node','controller' => 'node','action' => 'not_received_multiple', '?' => array_merge($_queries, array('keys' => array($moveContact['MoveContact']['id']),'model'=>'MoveContact','plugin'=>'Node','linkAction'=>'admin_manage_contact'))), array('title' => false, 'class' => 'btn btn-danger','data-dismiss='=>'modal')); ?>                        
                            </div>
                        </div>  
                        <?php endforeach?>                    
                </table>

                <div class="wd-select">

                    <div class="control-group">
                        <div class="controls wd-farming">
                            <select>
                                <option /><?php echo __d('system','Delete');?>
                            </select>
                            <button class="btn"><?php echo __d('system','Apply');?></button>
                        </div>
                    </div>
                </div>                                
            </div>-->
            <!--End-->
        </div>
    </div>    
</div>
<?php if(!empty($contacts)):?>
    <script type="text/javascript">
     $('document').ready(function(){
         var contacts = '<?php echo json_encode($contacts);?>';
         var obj = jQuery.parseJSON(contacts);
         var lenstr = obj.length;         
         for(objs in obj){
           var _getID = parseInt(obj[objs]['Contact']['id']);
           var _getImportant = parseInt(obj[objs]['Contact']['important']);  
           var _getFavourite = parseInt(obj[objs]['Contact']['favourite']);
           var inputImportant = $('div.checker input.input_importamt_'+_getID);
           var inputFavourite = $('div.checker input.input_favourite_'+_getID);            
           $('div.checker input.input_importamt_'+_getID).each(function(e){               
               if(_getImportant==1){inputImportant.parent().parent().find('span').addClass('checked');}                                                
           });            
           $('div.checker input.input_favourite_'+_getID).each(function(e){               
               if(_getFavourite==1){inputFavourite.parent().parent().find('span').addClass('checked');}                                                
           }); 
         }         
     });     
    </script>
<?php endif;?>
<?php         
    echo $this->Form->hidden('task', array('id' => 'task', 'value' => ''));
    echo $this->Form->end();
?>
<style type="text/css">
    .lbl-moved{text-decoration: underline;text-indent: initial;font-size: 16px;font-weight: bold;}    
td div.checker:nth-child(3) span{background: url(/img/star4.png) center no-repeat !important;} 
td div.checker:nth-child(3) span.checked{background: url(/img/star-lit4.png) center no-repeat !important;}
td div.checker:nth-child(2) span{background: url(/img/sprite_importance2.png) 0px 0px no-repeat !important;} 
td div.checker:nth-child(2) span.checked{background: url(/img/sprite_importance2.png) top right no-repeat !important;}
</style>